**********************************************************************************************
* Reproduces Figures A.15a
*
* Cloyne, Dimsdale and Hürtgen (2024) 								
*	"Are Tax Cuts Contractionary at the Zero Lower Bound? Evidence from a Century of Data"  	  		
*																			
* James Cloyne, Nicholas Dimsdale and Patrick Hürtgen, 2024
**********************************************************************************************


global outputfolder = "${rootfolder}/AE"
capture mkdir ${outputfolder}
global outputfolder = "${outputfolder}/${figure}"
capture mkdir ${outputfolder}

* control set specification
capture macro drop controlist 
capture macro drop controlist1 controlist2


*---------------------------------------------------------*
*-------------------- Setup --------------------*
*---------------------------------------------------------*

global approach = "LP"
global LHS = "smoothed"

* Sample harmonization
global harmonized = 0
global skipsample = 0	

* ---------- LP regression --------------- *
global qLags = 4  // lags for Tax shocks
global pLags = 4  // lags for controls
global gLags = 0  // lags for government spending shock controls
global hmax = ${hmax}

global controlist lnRealGDP lnRealTaxRev lnRealExp BankRate 		

/* -------------  Baseline LP ------------ */

use ${datapath}/${DataSetName},clear


foreach y in lnRealGDP  {

	preserve
	
	global depvar = "`y'"

	local labely : variable label $depvar
	local yname = subinstr("`labely'"," ","",.)

	do ${dofilepath}/LP_DataTransform_LR.do

	local labely : variable label $depvar
	local yname = subinstr("`labely'"," ","",.)

	log close _all

	local filename = "${approach}_`yname'ToTax_${LHS}"

	if "${shockversion}" == "LRConsistent" {

		if $skipsample == 1 {
			local filename = "`filename'_s" 
		}
	}

	log using ${outputfolder}/`filename', name(${approach}_${LHS}) text replace

	do ${dofilepath}/LP_IRFs.do

	if $PlotIRF == 1 & $saveFigs == 1 {
		gr export "${outputfolder}/IRF_`filename'.pdf", replace
	}

	list Quarters b u* d*   if !missing(Quarters)
	
	keep Quarters b u${alpha2}* d${alpha2}* u${alpha1}* d${alpha1}*
	drop if Quarters == .
	
	save "${outputfolder}/DataIRF_`filename'_Average_${LHS}.dta", replace
	export excel "${outputfolder}/DataIRF_`filename'_Average_${LHS}.xlsx", firstrow(variables)  keepcellfmt replace


	log close _all
	
	restore
}

global skipsample = 1





